﻿$(function () {

    /*响应部件*/


    //菜单小箭头
   // $(".TopNode").live("click", menuShow);

    //菜单事件
    $(".topLi span").live("click", menuAction);

    //Iframe加载遮罩层
    var iframe = document.getElementById('mainIframe');
    if (iframe.attachEvent) {
        iframe.attachEvent("onload", function () {
            removeLockDiv();
        });
    } else {
        iframe.onload = function () {
            removeLockDiv();
        };
    }


    /*END*/



    /*函数*/
    function menuShow() {
        var $topMenu = $(this);
        var isShow = false;
        isShow = $topMenu.attr("isShow");
        if (isShow=="true") {
            $topMenu.next("ul").hide();
            $topMenu.attr("isShow", false);
        } else if (isShow == "false") {
            $topMenu.next("ul").show();
            $topMenu.attr("isShow", true);
        }
    }

    function menuAction() {
        var item = $(this);
        var url = item.attr("url");
        LoadlockDiv();
        getMenuInfo(item);
        $(".mainIframe").attr("src", url);
    }

    function LoadlockDiv(domClass) {
        $("#mainDiv").block({
            message: '<p>Loading...</p>',
            css: { border: '0px solid blue',width:'150px',height:'38px',paddingTop:'20px'}
        });
    }

    function removeLockDiv()
    {
        $("#mainDiv").unblock();
    }

    //加载导航条
    function getMenuInfo(meunLink)
    {
        var $navigationDiv = $("#navigationDiv");
        var $narrows1 = $("<span>", { "class": "narrows", text: "〉" });//箭头
        var $narrows2 = $("<span>", { "class": "narrows", text: "〉" });//箭头
        $navigationDiv.empty();
        var currentText = meunLink.text();
        var parentText = "";
        if (meunLink.attr("parentId") != undefined)//如果是子节点  则获父亲节点的信息
        {
            var parentId = "Parent_" + meunLink.attr("parentId");
            parentText = $("#" + parentId).text();
        }
        var aindex = $("<a>", { html: "主页", href: "#","class":"nLink" });
        var cLink = $("<a>", { html: currentText, href: "#", "class": "nLink" });//子节点
        var pLink = $("<a>", { html: parentText, href: "#", "class": "nLink" });//父节点
        $navigationDiv.append(aindex).append($narrows1);
        if (parentText != "")
        {
            $navigationDiv.append(pLink).append($narrows2);
        }
        $navigationDiv.append(cLink);
    }
    /*END*/
})